package com.cy.store.controller;

import com.cy.store.entity.Order;
import com.cy.store.service.ICartService;
import com.cy.store.service.IOrderService;
import com.cy.store.util.JsonResults;
import com.cy.store.vo.CartVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 订单控制类
 */
@RestController //表示该控制类都以Json格式进行响应
//@Controller
@RequestMapping("orders")
public class OrderController extends BaseController {
    @Autowired
    private IOrderService orderService;

    @RequestMapping("create")
    public JsonResults<Order> createOrder(HttpSession httpSession, Integer aid,Integer[] cid){
        Integer uid = getuidFromSession(httpSession);
        String username = getUsernameFromSession(httpSession);
        Order data = orderService.insertOrder(uid,aid,username,cid);
        return new JsonResults<>(OK,data);
    }

}
